package com.changy.ai_tutor_for_dm.controller;

import com.changy.ai_tutor_for_dm.result.Result;
import com.changy.ai_tutor_for_dm.service.QuestionsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
public class QuestionsController {

    @Autowired
    private QuestionsService questionsService;

    @PostMapping("/questions")
    public Result addQuestions(@RequestBody Map<String, Object> requestbody) {
        try {
            questionsService.postQuestions(requestbody);
            return Result.success();
        } catch (Exception e) {
            return Result.error("上传题目失败");
        }
    }

    @GetMapping("/questions")
    public Result getQuestions(@RequestParam(required = false) String type,
                               @RequestParam(required = false) String keyword) {
        // Map<String, Object> questions = questionsService.getQuestions(type, keyword);
        return Result.success();
    }

}
